package com.yilin.tms.core.remote;

import com.yilin.tms.core.application.ReturnData;
import com.yilin.tms.core.commons.annotation.NoLoginSecurity;
import com.yilin.tms.core.components.interceptor.ReqProviderInterceptor;
import com.yilin.tms.core.entity.capital.TradeRecord;
import com.yilin.tms.core.entity.data.statistics.order.goods.GoodsStatistics;
import com.yilin.tms.core.entity.data.statistics.OrderStatistics;
import com.yilin.tms.core.entity.data.statistics.order.rob.RobStatistics;
import com.yilin.tms.core.entity.data.statistics.order.transit.TransitStatistics;
import com.yilin.tms.core.entity.order.goods.GoodsOrder;
import com.yilin.tms.core.entity.order.party.OrderAppraise;
import com.yilin.tms.core.entity.order.payment.OrderPaymentCost;
import com.yilin.tms.core.entity.order.payment.OrderRefundCost;
import com.yilin.tms.core.entity.order.payment.OrderSettlementCost;
import com.yilin.tms.core.entity.order.payment.ServicePaymentCost;
import com.yilin.tms.core.entity.order.rob.RobOrder;
import com.yilin.tms.core.entity.order.transit.TransitOrder;
import com.yilin.tms.core.entity.order.transit.TransitOrderNote;
import com.yilin.tms.core.entity.order.transit.TransitOrderNoteDetail;
import com.yilin.tms.core.entity.order.transit.TransitOrderVehicleRecord;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * 远程调用 订单服务
 *
 * @author zhangjinyuan
 * @date 2022/10/28
 */
@FeignClient(name = "order-service-provider", configuration = ReqProviderInterceptor.class)
public interface IOrderRemote {


    //---------------------------------------------------------货单区---------------------------------------------------------

    /**
     * 根据ID获取货单
     */
    @PostMapping(value = "/order/goods/getGoodsOrderById")
    ReturnData<GoodsOrder> getGoodsOrderById(@RequestParam("goodsOrderId") String goodsOrderId);


    //---------------------------------------------------------抢单区---------------------------------------------------------

    /**
     * 根据ID获取抢单
     */
    @PostMapping(value = "/order/rob/getRobOrderById")
    ReturnData<RobOrder> getRobOrderById(@RequestParam(value = "robOrderId") String robOrderId);


    //---------------------------------------------------------运单区---------------------------------------------------------

    /**
     * 更新运单ETC费用
     */
    @PostMapping(value = "/order/transit/updateOrderETCCost")
    ReturnData<Object> updateOrderETCCost(@RequestParam("transitOrderId") String transitOrderId, @RequestParam("etcCost") String etcCost);

    /**
     * 获取今日动态数据 - 发布货源 - 抢单 - 今日成交运单
     */
    @PostMapping(value = "/order/transit/getTodayStatistics")
    ReturnData<Map<String, Object>> getTodayStatistics();

    /**
     * 根据ID获取运单
     */
    @PostMapping(value = "/order/transit/getTransitOrderById")
    ReturnData<TransitOrder> getTransitOrderById(@RequestParam(value = "transitOrderId") String transitOrderId);

    /**
     * 根据运单号获取运单
     */
    @PostMapping(value = "/order/transit/getTransitOrderByNo")
    @NoLoginSecurity
    ReturnData<TransitOrder> getTransitOrderByNo(@RequestParam(value = "transportNo") String transportNo);

    /**
     * 批量获取运单
     */
    @PostMapping(value = "/order/transit/getTransitOrderListByIds")
    ReturnData<List<TransitOrder>> getTransitOrderListByIds(@RequestParam("transitOrderIds") String transitOrderIds);

    /**
     * 批量获取运单
     */
    @PostMapping(value = "/order/transit/getTransitOrderListByNos")
    ReturnData<List<TransitOrder>> getTransitOrderListByNos(@RequestParam(value = "transportNos") String transportNos);

    /**
     * 根据节点ID获取货物
     */
    @PostMapping(value = "/order/transit/getTransitNoteDetailList")
    ReturnData<List<TransitOrderNoteDetail>> getTransitNoteDetailList(@RequestParam(value = "transitOrderNoteId") String transitOrderNoteId);

    /**
     * 获取节点列表
     */
    @PostMapping(value = "/order/transit/getTransitOrderNoteList")
    @NoLoginSecurity
    ReturnData<List<TransitOrderNote>> getTransitOrderNoteList(@RequestParam(value = "transitOrderId") String transitOrderId, @RequestParam(value = "noteStatus") TransitOrderNote.NoteStatus noteStatus);

    /**
     * 批量获取多运单节点列表
     */
    @PostMapping(value = "/order/transit/getTransitOrderNoteListByTransitOrderIds")
    ReturnData<List<TransitOrderNote>> getTransitOrderNoteListByTransitOrderIds(@RequestParam(value = "transitOrderIds") String transitOrderIds);

    /**
     * 获取多运单节点货物列表
     */
    @PostMapping(value = "/order/transit/getAllTransitDetailListByTransitOrderIds")
    ReturnData<List<TransitOrderNoteDetail>> getAllTransitDetailListByTransitOrderIds(@RequestParam(value = "transitOrderIds") String transitOrderIds);

    /**
     * 根据ID获取货物
     */
    @PostMapping(value = "/order/transit/getAllTransitDetailList")
    ReturnData<List<TransitOrderNoteDetail>> getAllTransitDetailList(@RequestParam(value = "transitOrderId") String transitOrderId);

    /**
     * 根据运单运输记录
     */
    @PostMapping(value = "/order/transit/getTransitVehicleRecordList")
    ReturnData<List<TransitOrderVehicleRecord>> getTransitVehicleRecordList(@RequestParam(value = "transitOrderId") String transitOrderId);

    /**
     * 批量变更票单资料创建状态
     * 【司机票单专用】
     */
    @PostMapping(value = "/order/transit/updateTransitOrdersBillStatus")
    ReturnData<Object> updateTransitOrdersBillStatus(@RequestParam(value = "transitOrderIds") String transitOrderIds, @RequestParam(value = "status") Boolean status);

    /**
     * 省运管 获取平台未生成或生产失败的数据
     */
    @PostMapping(value = "/order/transit/getErrorTmsTransitOrder")
    ReturnData<List<TransitOrder>> getErrorTmsTransitOrder(@RequestParam(value = "transitTruckTowingType") Integer transitTruckTowingType);

    /**
     * 获取运单节点
     */
    @PostMapping(value = "/order/transit/getTransitOrderNoteById")
    ReturnData<TransitOrderNote> getTransitOrderNoteById(@RequestParam(value = "transitOrderNoteId") String transitOrderNoteId);

    //--------------------------------------------------------订单安全处理区----------------------------------------------------------

    /**
     * 一键下线用户所有货源
     */
    @PostMapping(value = "/order/security/recallGoodsOrderByAccountId")
    ReturnData<Object> recallGoodsOrderByAccountId(@RequestParam("accountId") String accountId);

    /**
     * 一键下线组织所有货源
     */
    @PostMapping(value = "/order/security/recallGoodsOrderByOrganizeId")
    ReturnData<Object> recallGoodsOrderByOrganizeId(@RequestParam("organizeId") String organizeId);

    /**
     * 检查是否存在货源
     * */
    @PostMapping(value = "/order/security/checkExistRunGoodsByAccountId")
    ReturnData<Boolean> checkExistRunGoodsByAccountId(@RequestParam("accountId") String accountId);

    /**
     * 检查是否存在货源
     * */
    @PostMapping(value = "/order/security/checkExistRunGoodsByOrganizeId")
    ReturnData<Boolean> checkExistRunGoodsByOrganizeId(@RequestParam("organizeId") String organizeId);

    /**
     * 检查是否存在订单
     * 包括抢单+运单
     * */
    @PostMapping(value = "/order/security/checkExistRunOrderByAccountId")
    ReturnData<Boolean> checkExistRunOrderByAccountId(@RequestParam("accountId") String accountId);

    /**
     * 检查是否存在订单
     * 包括抢单+运单
     * */
    @PostMapping(value = "/order/security/checkExistRunOrderByOrganizeId")
    ReturnData<Boolean> checkExistRunOrderByOrganizeId(@RequestParam("organizeId") String organizeId);

    //--------------------------------------------------------计算区----------------------------------------------------------

    @PostMapping(value = "/order/calculation/calculatePlatTechnicalFee")
    ReturnData<Double> calculatePlatTechnicalFee(@RequestParam("platId") String platId,@RequestParam("technicalFee") Double technicalFee);

    //
    @PostMapping(value = "/order/calculation/calculateTechnicalFee")
    ReturnData<Double> calculateTechnicalFee(@RequestParam("technicalFee") Double technicalFee);

    //--------------------------------------------------------预支付单区----------------------------------------------------------

    @PostMapping(value = "/order/payment/generateServicePayment")
    ReturnData<OrderPaymentCost> generateServicePayment(@RequestParam("tradeRecordId") String tradeRecordId);

    /**
     * 获取支付单
     */
    @PostMapping(value = "/order/payment/getOrderPaymentById")
    ReturnData<OrderPaymentCost> getOrderPaymentById(@RequestParam("paymentOrderId") String paymentOrderId);

    /**
     * 批量获取
     */
    @PostMapping(value = "/order/payment/getOrderPaymentListByIds")
    ReturnData<List<OrderPaymentCost>> getOrderPaymentListByIds(@RequestParam("paymentOrderIds") String paymentOrderIds);

    /**
     * 获取结算集合
     */
    @PostMapping(value = "/order/payment/getOrderSettlementListByIds")
    ReturnData<List<OrderSettlementCost>> getOrderSettlementListByIds(@RequestParam(value = "settlementOrderIds") String settlementOrderIds);

    /**
     * 批量获取
     */
    @PostMapping(value = "/order/payment/getOrderSettlementListByTransOrderIds")
    ReturnData<List<OrderSettlementCost>> getOrderSettlementListByTransOrderIds(@RequestParam(value = "transOrderIds") String transOrderIds);

    /**
     * 批量获取
     */
    @PostMapping(value = "/order/payment/getOrderRefundListByIds")
    ReturnData<List<OrderRefundCost>> getOrderRefundListByIds(@RequestParam(value = "refundOrderIds") String refundOrderIds);

    /**
     * 批量获取
     */
    @PostMapping(value = "/order/payment/getOrderRefundById")
    ReturnData<OrderRefundCost> getOrderRefundById(@RequestParam(value = "refundOrderId") String refundOrderId);

    /**
     * 获取集合
     */
    @PostMapping(value = "/order/payment/getServicePaymentListByIds")
    ReturnData<List<ServicePaymentCost>> getServicePaymentListByIds(@RequestParam(value = "servicePaymentIds") String servicePaymentIds);

    //-------------------------------------------------------获取评价-----------------------------------------------------------

    @PostMapping(value = "/order/appraise/getTopTenAppraiseList")
    ReturnData<List<OrderAppraise>> getTopTenAppraiseList(@RequestParam("organizeId") String organizeId);

    //-----------------------------------------------------订单-统计区-----------------------------------------------------------

    /**
     * 获取货源统计数据
     */
    @PostMapping(value = "/order/statistics/getGoodsStatistics")
    ReturnData<GoodsStatistics> getGoodsStatistics();

    /**
     * 获取运单统计数据
     */
    @PostMapping(value = "/order/statistics/getTransitStatistics")
    ReturnData<TransitStatistics> getTransitStatistics();

    /**
     * 获取抢单统计数据
     */
    @PostMapping(value = "/order/statistics/getRobStatistics")
    ReturnData<RobStatistics> getRobStatistics();

    /**
     * 获取清算统计数据
     */
    @PostMapping(value = "/order/statistics/getOrderStatistics")
    ReturnData<OrderStatistics> getOrderStatistics();

    /**
     * 根据组织ID查询前十天的抢单量
     */
    @PostMapping(value = "/order/statistics/getTradingTrendData")
    ReturnData<List<Map<String, Object>>> getTradingTrendData(@RequestParam(value = "organizeId") String organizeId);

    //----------------------------------------------------------移植：计划于2023年10月10日删除--------------------------------------------------------

    @PostMapping(value = "/order/migration/updateGetPaymentDataByOrderId")
    ReturnData<OrderPaymentCost> updateGetPaymentDataByOrderId(@RequestParam(value = "transOrderId")String transOrderId,@RequestParam(value = "tradeNo") String tradeNo,@RequestParam(value = "bankFlowNo") String bankFlowNo,
                                                               @RequestParam(value = "paymentCapitalAccount") String paymentCapitalAccount,@RequestParam(value = "incomeCapitalAccount") String incomeCapitalAccount,
                                                               @RequestParam(value = "optUserId")String optUserId,@RequestParam(value = "optUserName") String optUserName,
                                                               @RequestParam(value = "payType")TradeRecord.PayType payType, @RequestParam(value = "tradeStatus") TradeRecord.TradeStatus tradeStatus,
                                                               @RequestParam(value = "payRemark")String payRemark, @RequestParam(value = "payCompleteTime")String payCompleteTime);
    @PostMapping(value = "/order/migration/updateGetSettlementDataByOrderId")
    ReturnData<OrderSettlementCost> updateGetSettlementDataByOrderId(@RequestParam(value = "transOrderId")String transOrderId,@RequestParam(value = "tradeNo") String tradeNo,@RequestParam(value = "bankFlowNo") String bankFlowNo,
                                                               @RequestParam(value = "paymentCapitalAccount") String paymentCapitalAccount,@RequestParam(value = "incomeCapitalAccount") String incomeCapitalAccount,
                                                               @RequestParam(value = "optUserId")String optUserId,@RequestParam(value = "optUserName") String optUserName,
                                                               @RequestParam(value = "tradeStatus") TradeRecord.TradeStatus tradeStatus,
                                                               @RequestParam(value = "payRemark")String payRemark, @RequestParam(value = "payCompleteTime")String payCompleteTime);
    //----------------------------------------------------------任务区--------------------------------------------------------

    /**
     * 通知支付结果
     * 服务之间通知，服务发送时，保存密钥对，公钥发送，私钥保存，接收时匹配密钥对
     * 这里无需登录，因为收到通知没有登录支持
     */
    @PostMapping(value = "/order/task/updateOrderPaymentResult")
    @NoLoginSecurity
    ReturnData<Object> updateOrderPaymentResult(@RequestParam("tradeRecordIds") String tradeRecordIds);

    /**
     * 定时任务 自动评价
     */
    @PostMapping(value = "/order/task/autoOrderAppraise")
    @NoLoginSecurity
    ReturnData<Object> autoOrderAppraise();

    @PostMapping(value = "/order/task/taskDispatchOrder")
    @NoLoginSecurity
    ReturnData<Object> taskDispatchOrder();

    @PostMapping(value = "/order/task/gatherAutoSure")
    @NoLoginSecurity
    ReturnData<Object> gatherAutoSure();

    /**
     * 定时任务 24小时未生成运单得抢单自动作废
     */
    @PostMapping(value = "/order/task/autoScrapRobOrder")
    @NoLoginSecurity
    ReturnData<Object> autoScrapRobOrder();

    /**
     * 定时任务 货源自动下线
     */
    @PostMapping(value = "/order/task/timerRecallGoodsOrder")
    @NoLoginSecurity
    ReturnData<Object> timerRecallGoodsOrder();


}
